function add(){

	var name = $("#sname").val().trim();
	var price = $("#sprice").val().trim();
	var num = $("#snum").val().trim();
	var leib = $("#sleib").val().trim();
	
//	alert(id+name+price);

	$("#waring_name").html("");
	$("#waring_price").html("");
	$("#waring_num").html("");
	$("#waring_leib").html("");
	var ok = true;
	
	if(name == ""){
		$("#waring_name").html("商品名称不能为空");
		ok = false;
	}
	if(price == ""){
		$("#waring_price").html("商品价格不能为空");
		ok = false;
	}
	if(num == ""){
		$("#waring_num").html("商品数量不能为空");
		ok = false;
	}
	if(leib == ""){
		$("#waring_leib").html("商品类别不能为空");
		ok = false;
	}
	if(ok){
		//http://localhost:8080/commodity/commodtiy/commodtiyadd.do?sname=sdf&&sprice=98.00&&snum=8&&sleib=jiao
		
		$.ajax({
			url:path+"/commodtiy/commodtiyadd.do",
			type:"post",
			data:{"sname":name,
				  "sprice":price,
				  "snum":num,
				  "sleib":leib
				 },
			dataType:"json",
			success:function(result){
				if(result.status == 0){
					alert(result.msg);
					window.location.href = "one.jsp";
				}
			},
			error:function(){
				alert("添加失败");
			}
		});
		
	}

}